package cn.rkylin.oms.warehouseDocking.dao;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Repository;

import cn.rkylin.core.IDataBaseFactory;
import cn.rkylin.oms.warehouseDocking.domain.Stor;

/**
 * 仓库数据访问层具体实现
 * 
 * @author jipengcheng
 * @created 2017年10月17日
 */
@Repository(value = "iStorDAO")
public class StorDAOImpl implements IStorDAO {

    @Autowired
    protected IDataBaseFactory dao;

    private static final String SelectInfoStorByPrjId = "selectInfoStorByPrjId";
    private static final String SELECT_INFO_STOR_BY_ID = "selectInfoStorById";
    private static final String SELECT_RETURN_STOR_BY_STORID_AND_SHOPID = "selectReturnStorId";

    @Override
    public List<Stor> selectInfoStorByPrjId(Map<String, Object> reqMap) throws Exception {
        List<Stor> rList = dao.findAllList(SelectInfoStorByPrjId, reqMap);
        return rList;
    }

    /**
     * 根据仓库ID获取仓库信息
     *
     * @param storId
     * @return
     */
    @Override
    public Stor selectStorInfo(String storId) throws Exception {
        return (Stor)dao.find(SELECT_INFO_STOR_BY_ID,storId);
    }

    @Override
    public String selectReturnStorId(String storId, String shopId,String prjId) throws Exception {
        Map<String,String> paramMap = new HashMap<String,String>();
        paramMap.put("storId", storId);
        paramMap.put("shopId", shopId);
        paramMap.put("prjId", prjId);
        return (String) dao.find(SELECT_RETURN_STOR_BY_STORID_AND_SHOPID, paramMap);
    }
}
